---
title: Contacts router
description: An overview of the Contacts router
---

## Procedures

The contacts router has the following procedures:

### Get contact by id

Returns a contact by id.

- Access: `@member`

```typescript
// Client components
const { data } = useQuery(trpc.contacts.byId.queryOptions({
  id: '',
  workspaceId: '',
}))

// Server components
const data = await caller.contacts.byId({
  id: '',
  workspaceId: '',
})
```

### List contacts by type

List all contacts by type.

- Access: `@member`

```typescript
// Client components
const { data } = useQuery(trpc.contacts.listByType.queryOptions({
  type: '',
  workspaceId: '',
}))

// Server components
const data = await caller.contacts.listByType({
  type: '',
  workspaceId: '',
})
```

### Create a contact

Create a new contact in the workspace.

- Access: `@member`

```typescript
// Client components
const { data } = useMutation(trpc.contacts.create.mutationOptions())

// Server components
const data = await caller.contacts.create()
```

### Update a contact

Update a contact.

- Access: `@member`

```typescript
// Client components
const { data } = useMutation(trpc.contacts.update.mutationOptions())

// Server components
const data = await caller.contacts.update()
```

### List contact activity

Returns the latest activity of a contact.

- Access: `@member`

```typescript
// Client components
const { data } = useQuery(trpc.contacts.activitiesById.queryOptions({
  id: '',
  workspaceId: '',
}))

// Server components
const data = await caller.contacts.activitiesById({
  id: '',
  workspaceId: '',
})
```

### Add a comment to a contact

Add a comment to a contact.

- Access: `@member`

```typescript
// Client components
const { mutate } = useMutation(trpc.contacts.addComment.mutationOptions())

mutate({
  input: {
    id: '',
    workspaceId: '',
    comment: '',
  },
})

// Server components
const data = await caller.contacts.addComment({
  input: {
    id: '',
    workspaceId: '',
    comment: '',
  },
})
```

### Remove a comment

Remove a comment from a contact.

- Access: `@member`

```typescript
// Client components
const { mutate } = useMutation(trpc.contacts.removeComment.mutationOptions())

mutate({
  input: {
    workspaceId: '',
    commentId: '',
  },
})

// Server components
const data = await caller.contacts.removeComment({
  input: {
    workspaceId: '',
    commentId: '',
  },
})
```

### Update tags

Update the tags of a contact. Removes any tags not included in the list.

- Access: `@member`

```typescript
// Client components
const { mutate } = useMutation(trpc.contacts.updateTags.mutationOptions())

mutate({
  input: {
    id: '',
    workspaceId: '',
    tags: [],
  },
})

// Server components
const data = await caller.contacts.updateTags({
  input: {
    id: '',
    workspaceId: '',
    tags: [],
  },
})
```
